<%@ page import="com.tencent.albert.weixin.driver.bean.*" %>
<%@ page import="com.tencent.albert.weixin.driver.utils.WeixinUtil" %>
<%@ page import="com.tencent.albert.weixin.driver.Constants" %>
<%@ page import="java.util.*" %>
<%--
    Document   : getQrcodeTicket
    Created on : 2015-5-25 11:24:57
    Author     : neal
--%>


<%@page contentType="text/html" pageEncoding="UTF-8" %>

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>JSP Page</title>
</head>
<body>

<form action="" method="post">

</form>
<%
    // 调用接口获取access_token
    AccessToken at = WeixinUtil.getAccessToken(Constants.appId, Constants.appSecret);


    if (null != at) {
        long id1 = 1001;
        String name1 = "58";
        String result1 = WeixinUtil.getQrcodeTicket("limit", 0, id1, name1, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result1 + "'>" + name1 + "</a>");

        long id2 = 1002;
        String name2 = "赶集";
        String result2 = WeixinUtil.getQrcodeTicket("limit", 0, id2, name2, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result2 + "'>" + name2 + "</a>");

        long id3 = 1003;
        String name3 = "搜房";
        String result3 = WeixinUtil.getQrcodeTicket("limit", 0, id3, name3, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result3 + "'>" + name3 + "</a>");

        long id4 = 1004;
        String name4 = "列表";
        String result4 = WeixinUtil.getQrcodeTicket("limit", 0, id4, name4, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result4 + "'>" + name4 + "</a>");

        long id5 = 1005;
        String name5 = "百姓网";
        String result5 = WeixinUtil.getQrcodeTicket("limit", 0, id5, name5, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result5 + "'>" + name5 + "</a>");

        long id6 = 1006;
        String name6 = "安居客";
        String result6 = WeixinUtil.getQrcodeTicket("limit", 0, id6, name6, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result6 + "'>" + name6 + "</a>");


        long id7 = 1007;
        String name7 = "腾讯BBS";
        String result7 = WeixinUtil.getQrcodeTicket("limit", 0, id7, name7, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result7 + "'>" + name7 + "</a>");

        long id8 = 1008;
        String name8 = "豆瓣";
        String result8 = WeixinUtil.getQrcodeTicket("limit", 0, id8, name8, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result8 + "'>" + name8 + "</a>");

        long id9 = 1009;
        String name9 = "云来";
        String result9 = WeixinUtil.getQrcodeTicket("limit", 0, id9, name9, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result9 + "'>" + name9 + "</a>");

        long id10 = 1010;
        String name10 = "线下地推";
        String result10 = WeixinUtil.getQrcodeTicket("limit", 0, id10, name10, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result10 + "'>" + name10 + "</a>");

        long id11 = 1011;
        String name11 = "David";
        String result11 = WeixinUtil.getQrcodeTicket("limit", 0, id11, name11, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result11 + "'>" + name11 + "</a>");

        long id12 = 1012;
        String name12 = "Amy";
        String result12 = WeixinUtil.getQrcodeTicket("limit", 0, id12, name12, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result12 + "'>" + name12 + "</a>");

        long id13 = 1013;
        String name13 = "hills";
        String result13 = WeixinUtil.getQrcodeTicket("limit", 0, id13, name13, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result13 + "'>" + name13 + "</a>");

        long id14 = 1014;
        String name14 = "brain";
        String result14 = WeixinUtil.getQrcodeTicket("limit", 0, id14, name14, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result14 + "'>" + name14 + "</a>");

        long id15 = 1015;
        String name15 = "ken";
        String result15 = WeixinUtil.getQrcodeTicket("limit", 0, id15, name15, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result15 + "'>" + name15 + "</a>");

        long id16 = 1016;
        String name16 = "Ace";
        String result16 = WeixinUtil.getQrcodeTicket("limit", 0, id16, name16, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result16 + "'>" + name16 + "</a>");

        long id17 = 1017;
        String name17 = "ricky";
        String result17 = WeixinUtil.getQrcodeTicket("limit", 0, id17, name17, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result17 + "'>" + name17 + "</a>");

        long id18 = 1018;
        String name18 = "stefan";
        String result18 = WeixinUtil.getQrcodeTicket("limit", 0, id18, name18, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result18 + "'>" + name18 + "</a>");

        long id19 = 1019;
        String name19 = "joe";
        String result19 = WeixinUtil.getQrcodeTicket("limit", 0, id19, name19, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result19 + "'>" + name19 + "</a>");

        long id20 = 1020;
        String name20 = "Tom";
        String result20 = WeixinUtil.getQrcodeTicket("limit", 0, id20, name20, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result20 + "'>" + name20 + "</a>");

        long id21 = 1021;
        String name21 = "king";
        String result21 = WeixinUtil.getQrcodeTicket("limit", 0, id21, name21, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result21 + "'>" + name21 + "</a>");

        long id22 = 1022;
        String name22 = "dik";
        String result22 = WeixinUtil.getQrcodeTicket("limit", 0, id22, name22, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result22 + "'>" + name22 + "</a>");

        long id23 = 1023;
        String name23 = "daman";
        String result23 = WeixinUtil.getQrcodeTicket("limit", 0, id23, name23, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result23 + "'>" + name23 + "</a>");

        long id24 = 1024;
        String name24 = "jeff";
        String result24 = WeixinUtil.getQrcodeTicket("limit", 0, id24, name24, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result24 + "'>" + name24 + "</a>");


        long id25 = 1025;
        String name25 = "A";
        String result25 = WeixinUtil.getQrcodeTicket("limit", 0, id25, name25, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result25 + "'>" + name25 + "</a>");

        long id26 = 1026;
        String name26 = "B";
        String result26 = WeixinUtil.getQrcodeTicket("limit", 0, id26, name26, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result26 + "'>" + name26 + "</a>");

        long id27 = 1010;
        String name27 = "C";
        String result27 = WeixinUtil.getQrcodeTicket("limit", 0, id27, name27, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result27 + "'>" + name27 + "</a>");

        long id28 = 1028;
        String name28 = "D";
        String result28 = WeixinUtil.getQrcodeTicket("limit", 0, id28, name28, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result28 + "'>" + name28 + "</a>");

        long id29 = 1029;
        String name29 = "E";
        String result29 = WeixinUtil.getQrcodeTicket("limit", 0, id29, name29, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result29 + "'>" + name29 + "</a>");

        long id30 = 1030;
        String name30 = "F";
        String result30 = WeixinUtil.getQrcodeTicket("limit", 0, id30, name30, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result30 + "'>" + name30 + "</a>");

        long id31 = 1031;
        String name31 = "Test";
        String result31 = WeixinUtil.getQrcodeTicket("limit", 0, id31, name31, at.getAccess_Token());
        out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=" + result31 + "'>" + name31 + "</a>");
    }


    // if (null != at) {
    //     //20151020线下地推，用于宣传海报、报亭、便利店
    //     for (int i = 1; i <= 100; i++) {
    //         long id = i;
    //         String name = String.valueOf(i);
    //         String result = WeixinUtil.getQrcodeTicket("limit",0,id,name,at.getAccess_Token());
    //         out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="+result+"'>"+name+"</a>");
    //     }
    // }

    if (null != at) {
        //20151021 neal 要的，110个二维码（id要随机）
        Set<Integer> set = new HashSet<Integer>();
        while (set.size() < 40) {
            Random random = new Random();
            int a = random.nextInt(3000) % (3000 - 2001) + 2000;
            set.add(a);
        }

        for (Integer i : set) {
            long id = i;
            String name = String.valueOf((i+100000));
            String result = WeixinUtil.getQrcodeTicket("limit",0,id,name,at.getAccess_Token());
            out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="+result+"'>"+name+"</a>");
        }

//        List<Integer> list = new ArrayList<Integer>();
//        for (Integer i : set) {
//            list.add(i);
//        }
//
//        for(int i = 101; i < 220; i++) {
//            long id = i;
//            String name = String.valueOf(list.get(i-100) + 100000);
//            String result = WeixinUtil.getQrcodeTicket("limit",0,id,name,at.getAccess_Token());
//            out.println("<a href='https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket="+result+"'>"+name+"</a>");
//        }

    }


%>

</body>
</html>
